package com.task.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.ObjectUtils;

/**
 * @Author 迪迦.
 * @Date 2023/5/18 17:41
 */
public enum QuestionInfoTypeEnum {
  PROXY(0, "代理平台问题", "data_proxy", "data_proxy_platform", "PROXY_PLATFORM_CODE"),
  IP_FRAUD(1, "反欺诈平台问题", "data_ip_fraud", "data_ip_fraud_platform", "IP_FRAUD_PLATFORM_CODE"),
  DEVICE_FRAUD(2, "设备欺诈平台问题", "data_device_fraud", "data_device_fraud_platform", "DEVICE_FRAUD_PLATFORM_CODE"),
  PLUGIN(3, "插件平台问题", "data_plugin", "data_plugin_platform", "PLUGIN_PLATFORM_CODE"),
  ENGINE(4, "引擎问题", "data_engine_scheme", "data_engine", ""),
  MISSION(5, "任务问题", "data_mission", "", ""),
  ;

  private Integer info;
  private String displayName;
  private String tableName;
  private String otherTableName;
  private String columnName;


  QuestionInfoTypeEnum(Integer info, String displayName, String tableName, String otherTableName, String columnName) {
    this.info = info;
    this.displayName = displayName;
    this.tableName = tableName;
    this.otherTableName = otherTableName;
    this.columnName = columnName;
  }

  public static QuestionInfoTypeEnum getEnumByInfo(int info) {
    if (!ObjectUtils.isEmpty(info)) {
      for (QuestionInfoTypeEnum value : QuestionInfoTypeEnum.values()) {
        if (info == value.getInfo()) {
          return value;
        }
      }
    }
    return null;
  }

  public static QuestionInfoTypeEnum getEnumByName(String name) {
    if (!ObjectUtils.isEmpty(name)) {
      for (QuestionInfoTypeEnum value : QuestionInfoTypeEnum.values()) {
        if (name.equals(value.name())) {
          return value;
        }
      }
    }
    return null;
  }

  /**
   * 获取列表.
   */
  public static List<Map<String, Object>> getList() {
    List<Map<String, Object>> list = new ArrayList<>();
    for (QuestionInfoTypeEnum value : QuestionInfoTypeEnum.values()) {
      Map<String, Object> map = new HashMap<>();
      map.put("value", value.name());
      map.put("label", value.getDisplayName());
      map.put("displayName", value.getDisplayName());
      list.add(map);
    }
    return list;
  }

  QuestionInfoTypeEnum() {
  }

  public Integer getInfo() {
    return info;
  }

  public String getDisplayName() {
    return displayName;
  }

  public String getTableName() {
    return tableName;
  }

  public String getColumnName() {
    return columnName;
  }

  public String getOtherTableName() {
    return otherTableName;
  }
}
